<%@ include file="/taglibs.jsp"%>
<jsp:directive.page import="java.util.Random"/>
<jsp:directive.page import="java.util.Date"/>
<%if(session.getAttribute("randFormID") == null){
	Random gen = new Random(new Date().getTime());
	session.setAttribute("randFormID", gen.nextInt() + "");
}%>

<title>Winter War Administration - Tables</title>

<button onclick="location.href='table.do?method=edit&amp;conID=${conID}'">Add Table</button>

<table class="list">
	<thead>
		<tr>
			<th><bean:message key="table.tableName"/></th>
			<th><bean:message key="table.physicalTables"/></th>
			<td></td>
		</tr>
	</thead>
	<tbody>
		<c:forEach var="table" items="${tables}" varStatus="status">
			<c:choose>
				<c:when test="${status.count % 2 == 0}"><tr class="even"></c:when>
				<c:otherwise><tr class="odd"></c:otherwise>
			</c:choose>
				<td><a href="table.do?method=edit&amp;tableID=${table.tableID}&amp;conID=${table.conID }">${table.tableName}</a></td>
				<td>${table.physicalTables}</td>
				<td></td>
			</tr>
		</c:forEach>
		<tr>
			<html:form action="/wwadmin/table" focus="table.tableName">
				<input type="hidden" name="method" value="save"/>
				<input type="hidden" name="formID" value="<%=session.getAttribute("randFormID") %>"/>
				<input type="hidden" name="conID" value="${conID}"/>
				<td><html:text property="table.tableName" value=""/></td>
				<td><html:text property="table.physicalTables" value=""/></td>
				<td><html:submit>Save</html:submit></td>
			</html:form>
		</tr>
	</tbody>
</table>